import uvicorn
import asyncio
from fastapi import FastAPI
from pydantic import BaseModel

class Item(BaseModel):  # 定义一个类用作参数
    name: str
    age: int
    height: float
    is_offer: bool = None  # 该字段可为空


app = FastAPI()
server = None

@app.get("/executeflow")
async def executeFlow(id: str):
    import application
    application.g_App.pushMessage("FlowManager", "ExecutFlow", id)
    return {
        "id": id
    }

def shutdown():
    global server
    if server:
        server.should_exit = True  # 通知 Uvicorn 退出

def start(port: int = 13400):
    global server
    config = uvicorn.Config(app, host="0.0.0.0", port=port)
    server = uvicorn.Server(config)
    asyncio.run(server.serve())

